﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Plugins.Engine
{
    [Serializable]
    public class PluginMediator<T>
    {
        private readonly PluginDelegateMediator _delegateMediator = new PluginDelegateMediator();

        public void Register<TDelegate>(T target, string action, TDelegate delegateMethod)
        {
            if (delegateMethod is Delegate)
            {
                _delegateMediator.Add(target, action, delegateMethod);
            }
        }

        public void Unregister<TDelegate>(T target, string action, TDelegate delegateMethod)
        {
            if (delegateMethod is Delegate)
            {
                _delegateMediator.Remove(target, action, delegateMethod);
            }
        }

        public void Invoke<TDelegate>(string action, Action<TDelegate> actionMethod)
        {
            _delegateMediator.InvokeAction(action, actionMethod);
        }
    }
}
